<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title th:text="${question.title}"></title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/bootstrap-theme.css">
    <link rel="stylesheet" href="/css/editormd.preview.min.css">

    <script src="/js/jquery.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/deng_blog.css">
    <script src="/js/moment.js"></script>
    <script src="/js/dengblog.js"></script>
    <script src="/js/editormd.min.js"></script>
    <script src="/js/lib/marked.min.js"></script>
    <script src="/js/lib/prettify.min.js"></script>


</head>
<body>
<div th:insert="~{navigation::nav}"></div>
<div class="container-fluid main">
    <div class="row">
        <!--左边栏-->
        <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
            <!--正文-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4 class="question-title"><span th:text="${question.title}"></span></h4>
                <span class="text_desc">
                    作者:<span th:text="${question.user.name}"></span>&nbsp;|
                    发布时间：<span th:text="${#dates.format(question.gmtCreate,'yyyy-MM-dd hh:mm:ss')}"></span>&nbsp;|
                    阅读数:<span th:text="${question.viewCount}"></span>
                </span>
                <hr>
                <!--标签-->
                <!--<div th:text="${question.description}"></div>-->
                <div id="question-view">
                    <textarea style="display: none" th:text="${question.description}"></textarea>
                </div>
                <script type="text/javascript">
                    $(function() {
                        var testView = editormd.markdownToHTML("question-view", {
                        });
                    });
                </script>
                <hr>
                <span class="label label-info question-tag" th:each="tag:${question.tag.split(',')}">
                    <span class="label label-info" th:text="${tag}"></span>
                </span>

            </div>
            <!-- 编辑           -->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 deng-bottom_div"
                 th:if="${session.user!=null&&session.user.id==question.creator}">
                <hr>
                <a th:href="@{'/publish/'+${question.id}}" class="deng-menu" >
                    <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                    编辑
                </a>
            </div>
            <!--  回复内容展示          -->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 deng-bottom_div">
                <h4>
                    <span th:text="${question.commentCount}"></span>个回复
                </h4>
                <hr>
                <div th:each="comment:${comments}" class="comments">
                    <div class="media">
                        <div class="media-left">
                            <a href="#">
                                <img class="media-object img-rounded avatar" th:src="${question.user.avatarUrl}">
                            </a>
                        </div>
                        <div class="media-body" th:id="${'coment-body-'+comment.id}">
                            <h6 class="media-heading">
                                <span th:text="${question.user.name}"></span>
                            </h6>
                            <div th:text="${comment.content}"></div>
                            <div class="menu">
                                <span class="glyphicon glyphicon-thumbs-up icon"></span>
                                <span th:data-id="${comment.id}" onclick="collapseComments(this)" class="comment-icon">
                                    <span class="glyphicon glyphicon-comment"></span>
                                     <span th:text="${comment.commentCount}"></span>
                                </span>


                                <span class="pull-right"
                                      th:text="${#dates.format(question.gmtCreate,'yyyy-MM-dd')}"></span>
                                <!--二级评论-->
                                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 collapse comment-sub"
                                     th:id="'comment-'+${comment.id}">
                                    <div>
                                        <input type="text" class="form-control" placeholder="评论一下..."
                                               th:id="'input-'+${comment.id}">
                                        <button type="button" class="btn btn-success pull-right" onclick="comment(this)"
                                                th:data-id="${comment.id}">评论
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--回复区-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 deng-bottom_div" id="comment_section">
                <h4>提交回复</h4>
                <!--个人头像和名称-->
                <div class="media">
                    <div class="media-left">
                        <a href="#">
                            <img class="media-object img-rounded avatar"
                                 th:src="${session.user!=null?question.user.avatarUrl:'/images/default-avatar.png'}">
                        </a>
                    </div>
                    <div class="media-body">
                        <h6 class="media-heading">
                            <span th:text="${session.user!=null?question.user.name:'匿名用户'}"></span>
                        </h6>
                    </div>
                </div>
                <!--输入框-->
                <input type="hidden" id="question_id" th:value="${question.id}">
                <textarea class="form-control comment" rows="6" id="comment_content"></textarea>
                <button type="button" class="btn btn-success btn-comment" onclick="post()">回复</button>
            </div>

        </div>

        <!--右边栏-->
        <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4>发起人</h4>
                <hr>
                <div class="media">
                    <div class="media-left">
                        <a href="#">
                            <img class="media-object img-circle"
                                 th:src="${question.user.avatarUrl}"
                                 style="width: 45px;height: 45px">
                        </a>
                    </div>
                    <div class="media-body">
                        <h6 class="media-heading">
                            <span th:text="${question.user.name}"></span>
                        </h6>
                    </div>
                    <hr>
                </div>
            </div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h3>相关问题</h3>
                <ul class="question-related">
                    <li th:each="related:${relatedQuestions}">
                        <a th:href="@{'/question/'+${related.id}}" th:text="${related.title}"></a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
<div th:insert="~{footer::foot}"></div>
</body>
</html>